package com.hhsj.glidesource.builder;


/**
 * builder 原则是 属性不全的情况下不影响对象的主要功能。
 */

public class Test {

    public static void main(String[] args) {

        Student a = new Student.StudentBuilder().setClas("1").setGrade("2").setSchool("Nice").setAge("12").setName("Kite").setGender("male").build();
        Student b = new Student.StudentBuilder().setSchool("Nice").setAge("13").setName("Bob").setGender("female").build();

    }
}


class Student {
    String clas;
    String grade;
    String school;
    String name;
    String age;
    String gender;

    private Student() {

    }

    public static class StudentBuilder {
        private String clas;
        private String grade;
        private String school;
        private String name;
        private String age;
        private String gender;


        public StudentBuilder() {
        }


        public StudentBuilder setClas(String clas) {
            this.clas = clas;
            return this;
        }

        public StudentBuilder setGrade(String grade) {
            this.grade = grade;
            return this;
        }

        public StudentBuilder setSchool(String school) {
            this.school = school;
            return this;
        }

        public StudentBuilder setName(String name) {
            this.name = name;
            return this;
        }

        public StudentBuilder setAge(String age) {
            this.age = age;
            return this;
        }

        public StudentBuilder setGender(String gender) {
            this.gender = gender;
            return this;
        }

        public Student build() {

            Student student = new Student();
            student.clas = this.clas;
            student.grade = this.grade;
            student.school = this.school;
            student.name = this.name;
            student.age = this.age;
            student.gender = this.gender;
            return student;
        }
    }
}